/*
 * @Author: huangpan02
 * @Date: 2023-02-20 11:25:09
 * @LastEditTime: Please set LastEditors
 * @LastEditors: Please set LastEditors
 * @Description: 自有计量设备台账API
 */
import request from '@/utils/request'
import { faceProducerApiUrl } from '@/api/config'
// let _apiUrl = 'http://192.168.10.27:10400'
export default {
  /**
   * @description: 获取列表
   * @param {Object} data：body参数
   * @return {Promise}
   */
  list(data) {
    return request({
      url: `${faceProducerApiUrl}/configProject/queryConfigProjectPage`, method: 'post', data
    })
  },
  /**
 * @description: 查询设备配置历史版本
 * @param {String} data：body参数
 * @return {Promise}
 */
  queryHistoryVersion(data) {
    return request({
      url: `${faceProducerApiUrl}/configProject/queryHistoryVersion?versionId=${data.versionId}&id=${data.id}`, method: 'get'
    })
  },
  /**
   * @description: 保存草稿
   * @param {Object} data：body参数
   * @return {Promise}
   */
  saveDraft(data) {
    return request({
      url: `${faceProducerApiUrl}/configProject/saveDraft`, method: 'post', data
    })
  },
  /**
  * @description: 提交审批
  * @param {Object} data：body参数
  * @return {Promise}
  */
  commit(data) {
    return request({
      url: `${faceProducerApiUrl}/configProject/commit`, method: 'post', data
    })
  },
  /**
    * @description: 详情
    * @param {String} id：业务id
    * @return {Promise}
    */
  getDetail(data) {
    let url = data.versionId?`${faceProducerApiUrl}/configProject/getConfigProjectDetail?id=${data.id}&versionId=${data.versionId}`:`${faceProducerApiUrl}/configProject/getConfigProjectDetail?id=${data.id}`;
    return request({
      url:url, method: 'get'
    })
  },
  /**
 * @description: 删除
 * @param {String} id：业务id
 * @return {Promise}
 */
  delete(data) {
    return request({
      url: `${faceProducerApiUrl}/configProject/delDraftConfigPlan`, method: 'post', data
    })
  },
  /**
* @description: 选中导出
* @param {Object} data：body参数
* @return {Promise}
*/
  chooseToExport(data) {
    return request({
      url: `${faceProducerApiUrl}/configProject/chooseToExport`,
      method: 'post',
      data,
      responseType: 'blob',
      headers: {
        'Content-Type': 'application/json'
      }
    })
  },
  /**
* @description: 导出全部
* @param {Object} data：body参数
* @return {Promise}
*/
  exportAll(data) {
    return request({
      url: `${faceProducerApiUrl}/configProject/exportAll`,
      method: 'post',
      data,
      responseType: 'blob',
      headers: {
        'Content-Type': 'application/json'
      }
    })
  },
}